//
//  MenuViewController.m
//  Leisure
//
//  Created by xalo on 16/6/28.
//  Copyright © 2016年 Hero. All rights reserved.
//

#import "MenuViewController.h"


@interface MenuViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong)UITableView *tableView;

@end

@implementation MenuViewController

- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
        _tableView.dataSource = self;
        _tableView.delegate   = self;
        //设置tableView位置从200起
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.contentInset = UIEdgeInsetsMake(200, 0, 0, 0);
//        _tableView.backgroundColor = [UIColor cyanColor];
        
    }
    return _tableView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.tableView];
    self.automaticallyAdjustsScrollViewInsets = YES;
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"menuCell"];
    
}

#pragma -------tableViewDelegate-------
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.titleArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"menuCell" forIndexPath:indexPath];
    
    cell.textLabel.text = self.titleArray[indexPath.row];
//    cell.backgroundColor = [UIColor cyanColor];
    cell.selectedBackgroundView = [UIView new]; //取消选中背景
    
    return cell;
}
//点击cell的时候响应代理事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([self.delegate respondsToSelector:@selector(menuViewControllerDidClickWith:)]) {
        RightViewController *rightVC = self.vcArray[indexPath.row];
        rightVC.isSlider = NO;
        
        [self.delegate menuViewControllerDidClickWith:rightVC];
    }
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
